package com.td.erhome.ui.bughouse;

import android.support.v4.view.ViewPager;
import android.widget.ImageView;
import android.widget.TextView;

import com.td.erhome.R;
import com.td.erhome.adapter.PhotoViewPagerAdapter;
import com.td.erhome.base.BaseActivity;
import com.td.erhome.ui.widget.HackyViewPager;

import java.util.ArrayList;

import butterknife.Bind;
import butterknife.OnClick;

public class PhotoActivity extends BaseActivity {

    @Bind(R.id.back)
    ImageView mBack;
    @Bind(R.id.tv_title)
    TextView mTvTitle;
    @Bind(R.id.viewpager)
    HackyViewPager mViewpager;
    private int mSize;
    private int mNum;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_photo2;
    }

    @Override
    protected void initView() {

        mNum = getIntent().getIntExtra("num", 0);
        ArrayList<String> infoList = getIntent().getStringArrayListExtra("infoList");
        mSize = infoList.size();
        mTvTitle.setText(mNum +"/"+ mSize);

        mViewpager.setAdapter(new PhotoViewPagerAdapter(infoList,this));
        mViewpager.setCurrentItem(mNum);

        mViewpager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

            }
            @Override
            public void onPageSelected(int position) {
                mViewpager.setCurrentItem(position);
                mNum = position + 1;
                mTvTitle.setText(mNum+"/"+ mSize);
            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });

    }

    @Override
    protected void isLand() {
    }

    @Override
    protected void releaseResource() {

    }

    @OnClick(R.id.back)
    public void onViewClicked() {
        finish();
    }
}
